package ch.ebnoether.player;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

/**
 * Created with IntelliJ IDEA.
 * User: Frank
 * Date: 11.09.12
 * Time: 19:07
 * To change this template use File | Settings | File Templates.
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "player", propOrder = {"rang", "name", "punkte"})
@XmlRootElement(name = "player")
public class Player {
  private int rang;
  private String name;
  private int punkte;

  private Player() {
    rang = 0;
    name = "";
    punkte = 0;
  }

  public Player(String name) {
    this.name = name;
    this.rang = 0;
    this.punkte = 0;
  }

  public Player(int rang, String name, int punkte) {
    this.rang = rang;
    this.name = name;
    this.punkte = punkte;
  }

  public int getRang() {
    return rang;
  }

  public void setRang(int rang) {
    this.rang = rang;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getPunkte() {
    return punkte;
  }

  public void setPunkte(int punkte) {
    this.punkte = punkte;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Player player = (Player) o;

    if (punkte != player.punkte) return false;
    if (rang != player.rang) return false;
    if (name != null ? !name.equals(player.name) : player.name != null) return false;

    return true;
  }

  @Override
  public int hashCode() {
    int result = rang;
    result = 31 * result + (name != null ? name.hashCode() : 0);
    result = 31 * result + punkte;
    return result;
  }
}
